package org.exmaple.springframework.beans.factory.support;

import org.exmaple.springframework.beans.factory.config.SingletonBeanRegistry;

import java.util.HashMap;
import java.util.Map;

/**
 * @author DeYou
 * @date 2022/10/26
 */
public class DefaultSingletonBeanRegistry implements SingletonBeanRegistry {
    /**
     * 存储单例对象容器
     */
    private final Map<String,Object> singletonObjects = new HashMap<>();

    /**
     * 获取单例对象容器
     * @param beanName
     * @return
     */

    public Object getSingleton(String beanName) {
        return singletonObjects.get( beanName );
    }

    @Override
    public void registerSingleton(String beanName, Object singletonObject) {
        singletonObjects.put( beanName, singletonObject );
    }
}